﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using OnLineExam.Model;
using OnLineExam.BLL;
using NLog;
using HHG.Common;

public class BasePage : System.Web.UI.Page,IDisposable
{
    protected readonly Logger logger;//日志
    protected readonly System.Data.Entity.DbContext _ctx;

    public BasePage() {

        logger = LogManager.GetLogger(this.GetType().GetString());
        _ctx = new OnLineExam.Data.OnlineExamEntities();
    }
    public Users GetCurrentUser() {

		var userId = User.Identity.Name;
		 

		return UserManager.seluser(userId).First();

	}
    protected void WriteLog(string msg) {
        logger.Info(msg+" （" + User.Identity.Name + "）:");
         
    }
    protected void WriteLog(Exception ex, string msg="系统异常")
    {
        logger.Error(ex, msg + "（" + User.Identity.Name + "）:");

    }

    public override void Dispose()
    {
        _ctx.Dispose();
        base.Dispose();
    }
}